package com.jeenms.test.jvm;

public class GCDemo2 {
	static Object lock = new Object();

	public GCDemo2 instance = null;

	public GCDemo2() {
		byte[] byteArray2 = new byte[1024 * 1024 * 20];// 200mb
	}

	// -Xmx8m -Xms8m -XX:+PrintGCDetails --
	public static void main(String[] args) {
		try {
			GCDemo2 m1 = new GCDemo2();
			GCDemo2 m2 = new GCDemo2();
			
			m1.instance = m2;
			m2.instance = m1;
			
			//m1 = null;
			//m2 = null;
			
			//System.gc();
			while (true) {
				synchronized (lock) {
					System.out.println("2.无限期等待中...");
					lock.wait(); // 等待，直到其它线程调用 lock.notify()
				}
			}

		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		System.out.println("已退出!");

	}

}
